package com.thinkgem.jeesite.modules.cms.web;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.cms.entity.Record_task;
import com.thinkgem.jeesite.modules.cms.service.RecordService_task;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
@RequestMapping({ "${adminPath}/cms/record" })
public class RecordController extends BaseController {
	@Autowired
	private RecordService_task record_taskService;

	@ModelAttribute
	public Record_task get(@RequestParam(required = false) String id) {
		if (StringUtils.isNotBlank(id)) {
			return (Record_task) this.record_taskService.get(id);
		}
		return new Record_task();
	}

	@RequestMapping({ "list", "" })
	public String list(Record_task record, HttpServletRequest request,
			HttpServletResponse response, Model model) {
		String keyfield = request.getParameter("keyfield");
		Page<Record_task> page = this.record_taskService.findPage(new Page(
				request, response), record, true);
		model.addAttribute("page", page);
		return "modules/cms/recordList";
	}

	@RequestMapping({ "form" })
	public String form(Record_task record, Model model) {
		model.addAttribute("record", record);
		return "modules/cms/recordForm";
	}
}
